<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@include file="../template/header.jsp" %>
<div class="row-fluid">
	<form method="post">
		<%
		String search = request.getParameter("field");
		String value = request.getParameter("value");
		
		if(search == null)
		{
			search = "";
		}
		
		if(value == null)
		{
			value = "";
		}
		%>
		<select name="field">
			<option value="title" <%=search.equalsIgnoreCase("title") ? " selected=\"selected\"" : "" %>>Title</option>
			<option value="author" <%=search.equalsIgnoreCase("author") ? " selected=\"selected\"" : "" %>>Author</option>
			<option value="isbn" <%=search.equalsIgnoreCase("isbn") ? " selected=\"selected\"" : "" %>>ISBN</option>
			<option value="desc" <%=search.equalsIgnoreCase("desc") ? " selected=\"selected\"" : "" %>>Description</option>
		</select>
		<input type="text" name="value" value="<%=value%>" />
		<input type="submit" class="btn btn-success" value="Search" />
	</form>
	<table class="table">
		<c:forEach items="${model.books}" var="book">
			<tr>
				<td><img class="book_icon" src="${pageContext.request.contextPath}/assets/img/books/tn/${book.coverImage}" /></td>
				<td>${book.name}</td>
				<td>${book.shortDescription}</td>
				<td>$<fmt:formatNumber pattern="00.00" value="${book.price}"/></td>
				<td><a class="btn btn-wsu" href="${pageContext.request.contextPath}/books/view?id=${book.id}">Details</a></td>
			</tr>
		</c:forEach>
	</table>
</div>
<%@include file="../template/footer.jsp" %>